package com.hzy.fivepalace.common.type;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * 是否类型枚举
 */
public enum WhetherTypeEnum {
    NO(0, "否"), YES(1, "是"),LOGOUT(2, "注销"),;
    private int name;
    private String desc;

    WhetherTypeEnum(int name, String desc) {
        this.name = name;
        this.desc = desc;
    }

    public static WhetherTypeEnum getEnum(int id) {
        for (WhetherTypeEnum whetherTypeEnum : WhetherTypeEnum.values()) {
            if (whetherTypeEnum.getName() == id) {
                return whetherTypeEnum;
            }
        }
        return null;
    }

    public static List<Map> getList() {
        List<Map> list = new ArrayList<>();
        for (WhetherTypeEnum whetherTypeEnum : WhetherTypeEnum.values()) {
            Map map = new HashMap();
            map.put("name", whetherTypeEnum.getName());
            map.put("desc", whetherTypeEnum.getDesc());
            list.add(map);
        }
        return list;
    }

    public int getName() {
        return name;
    }

    public String getDesc() {
        return desc;
    }
}
